// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3) 

package com.nnee.p_pr.p_activity.p_view;

import android.content.Context;
import android.content.SharedPreferences;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.net.Uri;
import android.os.Handler;
import android.os.Looper;
import android.view.LayoutInflater;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import android.widget.ImageView;
import com.nnee.p_imgex.cls_ImageViewTouch;
import com.nnee.p_pr.p_activity.cls_PRISActivitySetting;
import com.nnee.p_pr.p_c.cls_a;
import java.io.File;
import java.util.*;

// Referenced classes of package com.nnee.p_pr.p_activity.view:
//            n, t, bx, ax, 
//            az, bg

public class cls_AdBar
{

    public AdBar(Context context, FrameLayout framelayout)
    {
        b = 0;
        c = 0;
        e = context;
        d = framelayout;
        f = new cls_n(e, d, null);
        e();
        d();
    }

    private Bitmap a(Uri uri)
    {
        return BitmapFactory.decodeFile(uri.getPath());
    }

    static FrameLayout a(AdBar adbar)
    {
        return adbar.d;
    }

    private void a(int l, int i1)
    {
        int j1;
        cls_t t1;
        Uri uri;
        j1 = 0;
        if(h.size() > 0)
        {
            l %= h.size();
            if(((List)h.get(l)).size() > 0)
                i1 %= ((List)h.get(l)).size();
        }
        t1 = (t)((List)h.get(l)).get(i1);
        uri = t1.a;
        if(uri != null) goto _L2; else goto _L1
_L1:
        int j2 = ((List)h.get(l)).size();
        if(j2 > 0 && ++i1 > j2)
        {
            l = (l + 1) % h.size();
            i1 = j1;
        }
        b = l;
        c = i1;
        g.postDelayed(new cls_bx(this, l, i1), t1.b);
_L3:
        return;
_L2:
        Bitmap bitmap = a(uri);
label0:
        {
            if(bitmap != null)
                break label0;
            int i2 = ((List)h.get(l)).size();
            Exception exception;
            int k1;
            ViewGroup viewgroup;
            int l1;
            if(i2 > 0 && ++i1 > i2)
                l = (l + 1) % h.size();
            else
                j1 = i1;
            b = l;
            c = j1;
            g.postDelayed(new cls_bx(this, l, j1), t1.b);
        }
          goto _L3
        viewgroup = (ViewGroup)LayoutInflater.from(e).inflate(0x7f030004, null);
        viewgroup.setVisibility(4);
        ((ImageViewTouch)viewgroup.findViewById(0x7f0d0012)).a(bitmap, true, true);
        k.addView(viewgroup, 0);
        f.a(viewgroup);
        l1 = ((List)h.get(l)).size();
        if(l1 > 0 && ++i1 > l1)
            l = (l + 1) % h.size();
        else
            j1 = i1;
        b = l;
        c = j1;
        g.postDelayed(new cls_bx(this, l, j1), t1.b);
          goto _L3
        exception;
        k1 = ((List)h.get(l)).size();
        if(k1 > 0 && ++i1 > k1)
            l = (l + 1) % h.size();
        else
            j1 = i1;
        b = l;
        c = j1;
        g.postDelayed(new cls_bx(this, l, j1), t1.b);
        throw exception;
    }

    private void a(long l)
    {
        a(((bg) (new cls_ax(this))), l);
    }

    static void a(AdBar adbar, int l, int i1)
    {
        adbar.a(l, i1);
    }

    static void a(AdBar adbar, long l)
    {
        adbar.a(l);
    }

    static Context b(AdBar adbar)
    {
        return adbar.e;
    }

    static int c(AdBar adbar)
    {
        return adbar.b;
    }

    static int d(AdBar adbar)
    {
        return adbar.c;
    }

    private void d()
    {
        long l = cls_PRISActivitySetting.n(e);
        long l1 = System.currentTimeMillis() - l;
        if(l1 >= 0x1d4c0L)
            f();
        else
            a(0x1d4c0L - l1);
    }

    private void e()
    {
        j.setOnClickListener(new cls_az(this));
    }

    static void e(AdBar adbar)
    {
        adbar.f();
    }

    private void f()
    {
        if(b() > 0)
        {
            SharedPreferences sharedpreferences = e.getSharedPreferences("ad_pref", 0);
            a(sharedpreferences.getInt("key_curpos", 0), sharedpreferences.getInt("key_curindex", 0));
            d.setVisibility(0);
        } else
        {
            d.setVisibility(8);
        }
    }

    public void a()
    {
        if(g != null)
            g.removeCallbacksAndMessages(null);
        if(i != null)
        {
            i.a();
            i = null;
        }
        if(k != null)
        {
            k.removeAllViews();
            k.clearAnimation();
            k = null;
        }
        if(d != null)
        {
            d.removeAllViews();
            d.clearAnimation();
        }
        if(h != null)
        {
            for(Iterator iterator = h.iterator(); iterator.hasNext(); ((List)iterator.next()).clear());
            h.clear();
            h = null;
        }
        if(j != null)
        {
            j.clearAnimation();
            j = null;
        }
    }

    public void a(bg bg, long l)
    {
        if(i == null)
            i = new cls_adBroadcast(e);
        i.a(bg, l);
    }

    public int b()
    {
        if(h == null)
            h = new ArrayList();
        h.clear();
        for(int l = 0; l < 10; l++)
        {
            File file = new File(com.nnee.p_pr.p_c.cls_a.a());
            if(!file.exists())
                continue;
            File afile[] = file.listFiles();
            if(afile == null || afile.length <= 0)
                continue;
            ArrayList arraylist = new ArrayList();
            arraylist.clear();
            int i1 = afile.length;
            for(int j1 = 0; j1 < i1; j1++)
            {
                cls_t t1 = new cls_t();
                t1.a = Uri.fromFile(afile[j1]);
                t1.b = 2000 * (j1 + 1) + l * 500;
                arraylist.add(t1);
            }

            h.add(arraylist);
        }

        return h.size();
    }

    /**
     * @deprecated Method c is deprecated
     */

    public void c()
    {
        this;
        JVM INSTR monitorenter ;
        if(i != null)
            i.a();
        this;
        JVM INSTR monitorexit ;
        return;
        Exception exception;
        exception;
        throw exception;
    }

    private final long a = 0x1d4c0L;
    private int b;
    private int c;
    private final FrameLayout d;
    private final Context e;
    private final n f;
    private final Handler g = new Handler(Looper.getMainLooper());
    private List h;
    private AdBroadcast i;
    private ImageView j;
    private FrameLayout k;

    private class cls_AdBroadcast extends BroadcastReceiver
    {

        /**
         * @deprecated Method a is deprecated
         */

        public void a()
        {
            this;
            JVM INSTR monitorenter ;
            h = null;
            if(d)
            {
                e.unregisterReceiver(this);
                d = false;
            }
            a(g);
            this;
            JVM INSTR monitorexit ;
            return;
            Exception exception;
            exception;
            throw exception;
        }

        /**
         * @deprecated Method a is deprecated
         */

        void a(PendingIntent pendingintent)
        {
            this;
            JVM INSTR monitorenter ;
            f.cancel(pendingintent);
            this;
            JVM INSTR monitorexit ;
            return;
            Exception exception;
            exception;
            throw exception;
        }

        /**
         * @deprecated Method a is deprecated
         */

        void a(PendingIntent pendingintent, long l)
        {
            this;
            JVM INSTR monitorenter ;
            long l1 = l + SystemClock.elapsedRealtime();
            f.set(2, l1, pendingintent);
            this;
            JVM INSTR monitorexit ;
            return;
            Exception exception;
            exception;
            throw exception;
        }

        /**
         * @deprecated Method a is deprecated
         */

        public void a(bg bg1, long l)
        {
            this;
            JVM INSTR monitorenter ;
            a(g);
            Uri uri = ContentUris.withAppendedId(b, 0L);
            Intent intent = (new Intent("com.android.im.intent.action.HEARTBEAT")).setDataAndType(uri, "vnd.android.im/heartbeat");
            g = PendingIntent.getBroadcast(e, 0, intent, 0);
            if(!d)
            {
                e.registerReceiver(this, IntentFilter.create("com.android.im.intent.action.HEARTBEAT", "vnd.android.im/heartbeat"));
                d = true;
            }
            h = bg1;
            a(g, l);
            this;
            JVM INSTR monitorexit ;
            return;
            Exception exception;
            exception;
            throw exception;
        }

        public void onReceive(Context context, Intent intent)
        {
            if(h != null)
                h.a();
        }

        private static final String a = "com.android.im.intent.action.HEARTBEAT";
        private static final Uri b = Uri.parse("content://im/heartbeat");
        private static final String c = "vnd.android.im/heartbeat";
        private static boolean d = false;
        private final Context e;
        private final AlarmManager f;
        private PendingIntent g;
        private bg h;


        public AdBroadcast(Context context)
        {
            e = context;
            f = (AlarmManager)context.getSystemService("alarm");
        }
    }

}
